{include file="header"}
<div style="padding: 20px;" class="layui-form adminmyucms">
	
<div class="layui-tab layui-tab-brief adminmyucms" lay-filter="docDemoTabBrief">
  <ul class="layui-tab-title">
  	{volist name=":fun_s('model',array('open'=>1),'px desc',100,1)" id="vo"}
    <a href="{:url('comment/index',array('id'=>$vo['id']))}"><li {if condition="$vo['id'] eq $id"}class="layui-this"{/if}>{$vo.title}</li></a>
     {/volist}
    <a href="{:url('comment/index',array('id'=>0))}"><li {if condition="0 eq $id"}class="layui-this"{/if}>单页</li></a>
  </ul>
</div> 
	
<div class="layui-btn-group" id="admin_set">
  <button class="layui-btn layui-btn-danger" data-url="{:url('comment/delss')}" lay-submit lay-filter="alldelete">删除选中</button>
  <a href="javascript:void(0);" onclick="location.reload()" class="layui-btn layui-btn-warm"> <i class="layui-icon">&#xe9aa;</i>刷新</a>
</div>
<table class="layui-table">
  <colgroup>
    <col width="80">
    <col width="50">
    <col width="80">
    <col width="100">
    <col width="200">
    <col width="500">
    <col width="150">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th width="40px" align="center"><input type="checkbox" name="checkAll" lay-filter="checkAll" title="全选"></th>
      <th>ID</th>
      <th>状态</th>
      <th>会员</th>
      <th>主题</th>
      <th>评论内容</th>
      <th>管理操作</th>
    </tr> 
  </thead>
  <tbody>
{if condition="$id eq '0'"}
{foreach name=":fun_S('comment',array('model'=>$id),'id desc','10',0)" item="v" key="k"}
    <tr>
      <td align="center" ><input type="checkbox" name="ids[{$v.id}]" lay-filter="checkOne" value="{$v.id}" title="选择"><input type="hidden" name="id" value="{$id}"></td>
      <th>{$v.id}</th>
      <th>
      <input type="checkbox" lay-skin="switch"  url="{:url("set/updateindex")}?id={$v.id}&m=comment&or=open"  lay-submit lay-filter="index" value="{$v.id}" lay-text="开启|关闭"  {if condition="$v['open'] eq 1"}checked{/if}>
      </th>
      <th><a target="_blank" href="*URL*/uid_{:fun_sc_p('member', array('userid'=>$v['uid']), 'userid')}.html">{:fun_sc_p('member', array('userid'=>$v['uid']), 'username')}</a></th>
      <th>
       <a target="_blank" href="*URL*/d_{:fun_sc_p('danye', array('id'=>$v['fid']), 'show')}.html"> {:cut(fun_sc_p('danye', array('id'=>$v['fid']), 'title'),10)}</a>
      </th>
      <th>{$v.content|htmltext|cut=###,300}</th>

      <th>
      	<div class="layui-btn-group" id="admin_set">
      		 <button  data-method="admin_set" member-id="{$v.id}" url="/admin.php/comment/edit/id/{$v.id}?model=danye" type="button" class="layui-btn layui-btn-lg layui-btn-normal layui-btn-sm"> <i class="layui-icon">&#xe642;</i>修改</button>
      		 <button  member-name="确定要删除该条评论吗？" url="{:url("set/delete")}?id={$v.id}&m=comment" lay-submit lay-filter="delete"  class="layui-btn layui-btn-danger layui-btn-sm"> <i class="layui-icon">&#xe640;</i>删除</button>
        </div>
      </th>
    </tr>
{/foreach} 
{else}
{foreach name=":fun_S('comment',array('model'=>$id),'id desc','10',0)" item="v" key="k"}
    <tr>
      <td align="center" ><input type="checkbox" name="ids[{$v.id}]" lay-filter="checkOne" value="{$v.id}" title="选择"><input type="hidden" name="id" value="{$id}"></td>
      <th>{$v.id}</th>
      <th>
      <input type="checkbox" lay-skin="switch"  url="{:url("set/updateindex")}?id={$v.id}&m=comment&or=open"  lay-submit lay-filter="index" value="{$v.id}" lay-text="开启|关闭"  {if condition="$v['open'] eq 1"}checked{/if}>
      </th>
      <th><a target="_blank" href="*URL*/uid_{:fun_sc_p('member', array('userid'=>$v['uid']), 'userid')}.html">{:fun_sc_p('member', array('userid'=>$v['uid']), 'username')}</a></th>
      <th>
       <a target="_blank" href="*URL*/s_{:m($v['model'])}_{$v.fid}.html"> {:cut(fun_sc_p(m($v['model']), array('id'=>$v['fid']), 'title'),10)}</a>
      </th>
      <th>{$v.content|htmltext|cut=###,300}</th>

      <th>
      	<div class="layui-btn-group" id="admin_set">
      		 <button  data-method="admin_set" member-id="{$v.id}" url="/admin.php/comment/edit/id/{$v.id}?model={:m($v['model'])}" type="button" class="layui-btn layui-btn-lg layui-btn-normal layui-btn-sm"> <i class="layui-icon">&#xe642;</i>修改</button>
      		 <button  member-name="确定要删除该条评论吗？" url="{:url("set/delete")}?id={$v.id}&m=comment" lay-submit lay-filter="delete"  class="layui-btn layui-btn-danger layui-btn-sm"> <i class="layui-icon">&#xe640;</i>删除</button>
        </div>
      </th>
    </tr>
{/foreach} 
{/if}
  </tbody>
</table>
<div class="pages">
{:fun_S('comment',array('model'=>$id),'id desc','10',0)->render()}
<div>
<div>
<script>
    layui.use(['layer','jquery','form', 'laydate'], function() {
        var form = layui.form,
            laydate = layui.laydate,
            $form = $('form'),
            jq = layui.jquery;
        form.on('select()', function(data) {
            $form.submit();
        });

        laydate.render({
            elem: '#startdate' //指定元素
                ,
            done: function(value, date) {
                $form.submit();
            }
        });
        laydate.render({
            elem: '#enddate' //指定元素
                ,
            done: function(value, date) {
                $form.submit();
            }
        });
  form.on('checkbox(checkAll)', function(data){
    if(data.elem.checked){
      jq("input[lay-filter='checkOne']").prop('checked',true);
    }else{
      jq("input[lay-filter='checkOne']").prop('checked',false);
    }
    form.render('checkbox');
  });  

  form.on('checkbox(checkOne)', function(data){
    var is_check = true;
    if(data.elem.checked){
      jq("input[lay-filter='checkOne']").each(function(){
        if(!jq(this).prop('checked')){ is_check = false; }
      });
      if(is_check){
        jq("input[lay-filter='checkAll']").prop('checked',true);
      }
    }else{
      jq("input[lay-filter='checkAll']").prop('checked',false);
    } 
    form.render('checkbox');
  });

  form.on('submit(alldelete)', function(data){
    var is_check = false;
    jq("input[lay-filter='checkOne']").each(function(){
      if(jq(this).prop('checked')){ is_check = true; }
    });
    if(!is_check){
      layer.msg('请选择数据', {icon: 2,anim: 6,time: 1000});
      return false;
    }
    var url= jq(this).data('url');
   
    layer.confirm('确定批量删除数据吗?', function(index){
      loading = layer.load(2, {
        shade: [0.2,'#000']
      });
      var param = data.field;
    
      jq.post(url,param,function(data){
        if(data.code == 200){
          layer.close(loading);
          layer.msg(data.msg, {icon: 1, time: 1000}, function(){
            location.reload();
          });
        }else{
          layer.close(loading);
          layer.msg(data.msg, {icon: 2,anim: 6, time: 1000});
        }
      });
    });
    return false;
  });
  }); 
</script>
{include file="footer"}